﻿using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using System;

namespace AbpCompanyName.AbpProjectName.Migrations;

public partial class Initial_Migrations : Migration
{
    protected override void Up(MigrationBuilder migrationBuilder)
    {
        migrationBuilder.CreateTable(
            name: "AbpEditions",
            columns: table => new
            {
                Id = table.Column<int>(nullable: false)
                    .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                CreationTime = table.Column<DateTime>(nullable: false),
                CreatorUserId = table.Column<long>(nullable: true),
                DeleterUserId = table.Column<long>(nullable: true),
                DeletionTime = table.Column<DateTime>(nullable: true),
                DisplayName = table.Column<string>(maxLength: 64, nullable: false),
                IsDeleted = table.Column<bool>(nullable: false),
                LastModificationTime = table.Column<DateTime>(nullable: true),
                LastModifierUserId = table.Column<long>(nullable: true),
                Name = table.Column<string>(maxLength: 32, nullable: false)
            },
            constraints: table =>
            {
                table.PrimaryKey("PK_AbpEditions", x => x.Id);
            });

        migrationBuilder.CreateTable(
            name: "AbpAuditLogs",
            columns: table => new
            {
                Id = table.Column<long>(nullable: false)
                    .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                BrowserInfo = table.Column<string>(maxLength: 256, nullable: true),
                ClientIpAddress = table.Column<string>(maxLength: 64, nullable: true),
                ClientName = table.Column<string>(maxLength: 128, nullable: true),
                CustomData = table.Column<string>(maxLength: 2000, nullable: true),
                Exception = table.Column<string>(maxLength: 2000, nullable: true),
                ExecutionDuration = table.Column<int>(nullable: false),
                ExecutionTime = table.Column<DateTime>(nullable: false),
                ImpersonatorTenantId = table.Column<int>(nullable: true),
                ImpersonatorUserId = table.Column<long>(nullable: true),
                MethodName = table.Column<string>(maxLength: 256, nullable: true),
                Parameters = table.Column<string>(maxLength: 1024, nullable: true),
                ServiceName = table.Column<string>(maxLength: 256, nullable: true),
                TenantId = table.Column<int>(nullable: true),
                UserId = table.Column<long>(nullable: true)
            },
            constraints: table =>
            {
                table.PrimaryKey("PK_AbpAuditLogs", x => x.Id);
            });

        migrationBuilder.CreateTable(
            name: "AbpUserAccounts",
            columns: table => new
            {
                Id = table.Column<long>(nullable: false)
                    .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                CreationTime = table.Column<DateTime>(nullable: false),
                CreatorUserId = table.Column<long>(nullable: true),
                DeleterUserId = table.Column<long>(nullable: true),
                DeletionTime = table.Column<DateTime>(nullable: true),
                EmailAddress = table.Column<string>(nullable: true),
                IsDeleted = table.Column<bool>(nullable: false),
                LastLoginTime = table.Column<DateTime>(nullable: true),
                LastModificationTime = table.Column<DateTime>(nullable: true),
                LastModifierUserId = table.Column<long>(nullable: true),
                TenantId = table.Column<int>(nullable: true),
                UserId = table.Column<long>(nullable: false),
                UserLinkId = table.Column<long>(nullable: true),
                UserName = table.Column<string>(nullable: true)
            },
            constraints: table =>
            {
                table.PrimaryKey("PK_AbpUserAccounts", x => x.Id);
            });

        migrationBuilder.CreateTable(
            name: "AbpUserLoginAttempts",
            columns: table => new
            {
                Id = table.Column<long>(nullable: false)
                    .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                BrowserInfo = table.Column<string>(maxLength: 256, nullable: true),
                ClientIpAddress = table.Column<string>(maxLength: 64, nullable: true),
                ClientName = table.Column<string>(maxLength: 128, nullable: true),
                CreationTime = table.Column<DateTime>(nullable: false),
                Result = table.Column<byte>(nullable: false),
                TenancyName = table.Column<string>(maxLength: 64, nullable: true),
                TenantId = table.Column<int>(nullable: true),
                UserId = table.Column<long>(nullable: true),
                UserNameOrEmailAddress = table.Column<string>(maxLength: 255, nullable: true)
            },
            constraints: table =>
            {
                table.PrimaryKey("PK_AbpUserLoginAttempts", x => x.Id);
            });

        migrationBuilder.CreateTable(
            name: "AbpUserOrganizationUnits",
            columns: table => new
            {
                Id = table.Column<long>(nullable: false)
                    .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                CreationTime = table.Column<DateTime>(nullable: false),
                CreatorUserId = table.Column<long>(nullable: true),
                OrganizationUnitId = table.Column<long>(nullable: false),
                TenantId = table.Column<int>(nullable: true),
                UserId = table.Column<long>(nullable: false)
            },
            constraints: table =>
            {
                table.PrimaryKey("PK_AbpUserOrganizationUnits", x => x.Id);
            });

        migrationBuilder.CreateTable(
            name: "AbpBackgroundJobs",
            columns: table => new
            {
                Id = table.Column<long>(nullable: false)
                    .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                CreationTime = table.Column<DateTime>(nullable: false),
                CreatorUserId = table.Column<long>(nullable: true),
                IsAbandoned = table.Column<bool>(nullable: false),
                JobArgs = table.Column<string>(maxLength: 1048576, nullable: false),
                JobType = table.Column<string>(maxLength: 512, nullable: false),
                LastTryTime = table.Column<DateTime>(nullable: true),
                NextTryTime = table.Column<DateTime>(nullable: false),
                Priority = table.Column<byte>(nullable: false),
                TryCount = table.Column<short>(nullable: false)
            },
            constraints: table =>
            {
                table.PrimaryKey("PK_AbpBackgroundJobs", x => x.Id);
            });

        migrationBuilder.CreateTable(
            name: "AbpLanguages",
            columns: table => new
            {
                Id = table.Column<int>(nullable: false)
                    .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                CreationTime = table.Column<DateTime>(nullable: false),
                CreatorUserId = table.Column<long>(nullable: true),
                DeleterUserId = table.Column<long>(nullable: true),
                DeletionTime = table.Column<DateTime>(nullable: true),
                DisplayName = table.Column<string>(maxLength: 64, nullable: false),
                Icon = table.Column<string>(maxLength: 128, nullable: true),
                IsDeleted = table.Column<bool>(nullable: false),
                LastModificationTime = table.Column<DateTime>(nullable: true),
                LastModifierUserId = table.Column<long>(nullable: true),
                Name = table.Column<string>(maxLength: 10, nullable: false),
                TenantId = table.Column<int>(nullable: true)
            },
            constraints: table =>
            {
                table.PrimaryKey("PK_AbpLanguages", x => x.Id);
            });

        migrationBuilder.CreateTable(
            name: "AbpLanguageTexts",
            columns: table => new
            {
                Id = table.Column<long>(nullable: false)
                    .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                CreationTime = table.Column<DateTime>(nullable: false),
                CreatorUserId = table.Column<long>(nullable: true),
                Key = table.Column<string>(maxLength: 256, nullable: false),
                LanguageName = table.Column<string>(maxLength: 10, nullable: false),
                LastModificationTime = table.Column<DateTime>(nullable: true),
                LastModifierUserId = table.Column<long>(nullable: true),
                Source = table.Column<string>(maxLength: 128, nullable: false),
                TenantId = table.Column<int>(nullable: true),
                Value = table.Column<string>(maxLength: 67108864, nullable: false)
            },
            constraints: table =>
            {
                table.PrimaryKey("PK_AbpLanguageTexts", x => x.Id);
            });

        migrationBuilder.CreateTable(
            name: "AbpNotifications",
            columns: table => new
            {
                Id = table.Column<Guid>(nullable: false),
                CreationTime = table.Column<DateTime>(nullable: false),
                CreatorUserId = table.Column<long>(nullable: true),
                Data = table.Column<string>(maxLength: 1048576, nullable: true),
                DataTypeName = table.Column<string>(maxLength: 512, nullable: true),
                EntityId = table.Column<string>(maxLength: 96, nullable: true),
                EntityTypeAssemblyQualifiedName = table.Column<string>(maxLength: 512, nullable: true),
                EntityTypeName = table.Column<string>(maxLength: 250, nullable: true),
                ExcludedUserIds = table.Column<string>(maxLength: 131072, nullable: true),
                NotificationName = table.Column<string>(maxLength: 96, nullable: false),
                Severity = table.Column<byte>(nullable: false),
                TenantIds = table.Column<string>(maxLength: 131072, nullable: true),
                UserIds = table.Column<string>(maxLength: 131072, nullable: true)
            },
            constraints: table =>
            {
                table.PrimaryKey("PK_AbpNotifications", x => x.Id);
            });

        migrationBuilder.CreateTable(
            name: "AbpNotificationSubscriptions",
            columns: table => new
            {
                Id = table.Column<Guid>(nullable: false),
                CreationTime = table.Column<DateTime>(nullable: false),
                CreatorUserId = table.Column<long>(nullable: true),
                EntityId = table.Column<string>(maxLength: 96, nullable: true),
                EntityTypeAssemblyQualifiedName = table.Column<string>(maxLength: 512, nullable: true),
                EntityTypeName = table.Column<string>(maxLength: 250, nullable: true),
                NotificationName = table.Column<string>(maxLength: 96, nullable: true),
                TenantId = table.Column<int>(nullable: true),
                UserId = table.Column<long>(nullable: false)
            },
            constraints: table =>
            {
                table.PrimaryKey("PK_AbpNotificationSubscriptions", x => x.Id);
            });

        migrationBuilder.CreateTable(
            name: "AbpTenantNotifications",
            columns: table => new
            {
                Id = table.Column<Guid>(nullable: false),
                CreationTime = table.Column<DateTime>(nullable: false),
                CreatorUserId = table.Column<long>(nullable: true),
                Data = table.Column<string>(maxLength: 1048576, nullable: true),
                DataTypeName = table.Column<string>(maxLength: 512, nullable: true),
                EntityId = table.Column<string>(maxLength: 96, nullable: true),
                EntityTypeAssemblyQualifiedName = table.Column<string>(maxLength: 512, nullable: true),
                EntityTypeName = table.Column<string>(maxLength: 250, nullable: true),
                NotificationName = table.Column<string>(maxLength: 96, nullable: false),
                Severity = table.Column<byte>(nullable: false),
                TenantId = table.Column<int>(nullable: true)
            },
            constraints: table =>
            {
                table.PrimaryKey("PK_AbpTenantNotifications", x => x.Id);
            });

        migrationBuilder.CreateTable(
            name: "AbpUserNotifications",
            columns: table => new
            {
                Id = table.Column<Guid>(nullable: false),
                CreationTime = table.Column<DateTime>(nullable: false),
                State = table.Column<int>(nullable: false),
                TenantId = table.Column<int>(nullable: true),
                TenantNotificationId = table.Column<Guid>(nullable: false),
                UserId = table.Column<long>(nullable: false)
            },
            constraints: table =>
            {
                table.PrimaryKey("PK_AbpUserNotifications", x => x.Id);
            });

        migrationBuilder.CreateTable(
            name: "AbpOrganizationUnits",
            columns: table => new
            {
                Id = table.Column<long>(nullable: false)
                    .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                Code = table.Column<string>(maxLength: 95, nullable: false),
                CreationTime = table.Column<DateTime>(nullable: false),
                CreatorUserId = table.Column<long>(nullable: true),
                DeleterUserId = table.Column<long>(nullable: true),
                DeletionTime = table.Column<DateTime>(nullable: true),
                DisplayName = table.Column<string>(maxLength: 128, nullable: false),
                IsDeleted = table.Column<bool>(nullable: false),
                LastModificationTime = table.Column<DateTime>(nullable: true),
                LastModifierUserId = table.Column<long>(nullable: true),
                ParentId = table.Column<long>(nullable: true),
                TenantId = table.Column<int>(nullable: true)
            },
            constraints: table =>
            {
                table.PrimaryKey("PK_AbpOrganizationUnits", x => x.Id);
                table.ForeignKey(
                    name: "FK_AbpOrganizationUnits_AbpOrganizationUnits_ParentId",
                    column: x => x.ParentId,
                    principalTable: "AbpOrganizationUnits",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

        migrationBuilder.CreateTable(
            name: "AbpUsers",
            columns: table => new
            {
                Id = table.Column<long>(nullable: false)
                    .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                AccessFailedCount = table.Column<int>(nullable: false),
                AuthenticationSource = table.Column<string>(maxLength: 64, nullable: true),
                ConcurrencyStamp = table.Column<string>(nullable: true),
                CreationTime = table.Column<DateTime>(nullable: false),
                CreatorUserId = table.Column<long>(nullable: true),
                DeleterUserId = table.Column<long>(nullable: true),
                DeletionTime = table.Column<DateTime>(nullable: true),
                EmailAddress = table.Column<string>(maxLength: 256, nullable: false),
                EmailConfirmationCode = table.Column<string>(maxLength: 328, nullable: true),
                IsActive = table.Column<bool>(nullable: false),
                IsDeleted = table.Column<bool>(nullable: false),
                IsEmailConfirmed = table.Column<bool>(nullable: false),
                IsLockoutEnabled = table.Column<bool>(nullable: false),
                IsPhoneNumberConfirmed = table.Column<bool>(nullable: false),
                IsTwoFactorEnabled = table.Column<bool>(nullable: false),
                LastLoginTime = table.Column<DateTime>(nullable: true),
                LastModificationTime = table.Column<DateTime>(nullable: true),
                LastModifierUserId = table.Column<long>(nullable: true),
                LockoutEndDateUtc = table.Column<DateTime>(nullable: true),
                Name = table.Column<string>(maxLength: 32, nullable: false),
                NormalizedEmailAddress = table.Column<string>(maxLength: 256, nullable: false),
                NormalizedUserName = table.Column<string>(maxLength: 32, nullable: false),
                Password = table.Column<string>(maxLength: 128, nullable: false),
                PasswordResetCode = table.Column<string>(maxLength: 328, nullable: true),
                PhoneNumber = table.Column<string>(nullable: true),
                SecurityStamp = table.Column<string>(nullable: true),
                Surname = table.Column<string>(maxLength: 32, nullable: false),
                TenantId = table.Column<int>(nullable: true),
                UserName = table.Column<string>(maxLength: 32, nullable: false)
            },
            constraints: table =>
            {
                table.PrimaryKey("PK_AbpUsers", x => x.Id);
                table.ForeignKey(
                    name: "FK_AbpUsers_AbpUsers_CreatorUserId",
                    column: x => x.CreatorUserId,
                    principalTable: "AbpUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
                table.ForeignKey(
                    name: "FK_AbpUsers_AbpUsers_DeleterUserId",
                    column: x => x.DeleterUserId,
                    principalTable: "AbpUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
                table.ForeignKey(
                    name: "FK_AbpUsers_AbpUsers_LastModifierUserId",
                    column: x => x.LastModifierUserId,
                    principalTable: "AbpUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

        migrationBuilder.CreateTable(
            name: "AbpFeatures",
            columns: table => new
            {
                Id = table.Column<long>(nullable: false)
                    .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                CreationTime = table.Column<DateTime>(nullable: false),
                CreatorUserId = table.Column<long>(nullable: true),
                Discriminator = table.Column<string>(nullable: false),
                Name = table.Column<string>(maxLength: 128, nullable: false),
                Value = table.Column<string>(maxLength: 2000, nullable: false),
                EditionId = table.Column<int>(nullable: true),
                TenantId = table.Column<int>(nullable: true)
            },
            constraints: table =>
            {
                table.PrimaryKey("PK_AbpFeatures", x => x.Id);
                table.ForeignKey(
                    name: "FK_AbpFeatures_AbpEditions_EditionId",
                    column: x => x.EditionId,
                    principalTable: "AbpEditions",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

        migrationBuilder.CreateTable(
            name: "AbpUserClaims",
            columns: table => new
            {
                Id = table.Column<long>(nullable: false)
                    .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                ClaimType = table.Column<string>(nullable: true),
                ClaimValue = table.Column<string>(nullable: true),
                CreationTime = table.Column<DateTime>(nullable: false),
                CreatorUserId = table.Column<long>(nullable: true),
                TenantId = table.Column<int>(nullable: true),
                UserId = table.Column<long>(nullable: false)
            },
            constraints: table =>
            {
                table.PrimaryKey("PK_AbpUserClaims", x => x.Id);
                table.ForeignKey(
                    name: "FK_AbpUserClaims_AbpUsers_UserId",
                    column: x => x.UserId,
                    principalTable: "AbpUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

        migrationBuilder.CreateTable(
            name: "AbpUserLogins",
            columns: table => new
            {
                Id = table.Column<long>(nullable: false)
                    .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                LoginProvider = table.Column<string>(maxLength: 128, nullable: false),
                ProviderKey = table.Column<string>(maxLength: 256, nullable: false),
                TenantId = table.Column<int>(nullable: true),
                UserId = table.Column<long>(nullable: false)
            },
            constraints: table =>
            {
                table.PrimaryKey("PK_AbpUserLogins", x => x.Id);
                table.ForeignKey(
                    name: "FK_AbpUserLogins_AbpUsers_UserId",
                    column: x => x.UserId,
                    principalTable: "AbpUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

        migrationBuilder.CreateTable(
            name: "AbpUserRoles",
            columns: table => new
            {
                Id = table.Column<long>(nullable: false)
                    .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                CreationTime = table.Column<DateTime>(nullable: false),
                CreatorUserId = table.Column<long>(nullable: true),
                RoleId = table.Column<int>(nullable: false),
                TenantId = table.Column<int>(nullable: true),
                UserId = table.Column<long>(nullable: false)
            },
            constraints: table =>
            {
                table.PrimaryKey("PK_AbpUserRoles", x => x.Id);
                table.ForeignKey(
                    name: "FK_AbpUserRoles_AbpUsers_UserId",
                    column: x => x.UserId,
                    principalTable: "AbpUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

        migrationBuilder.CreateTable(
            name: "AbpUserTokens",
            columns: table => new
            {
                Id = table.Column<long>(nullable: false)
                    .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                LoginProvider = table.Column<string>(nullable: true),
                Name = table.Column<string>(nullable: true),
                TenantId = table.Column<int>(nullable: true),
                UserId = table.Column<long>(nullable: false),
                Value = table.Column<string>(nullable: true)
            },
            constraints: table =>
            {
                table.PrimaryKey("PK_AbpUserTokens", x => x.Id);
                table.ForeignKey(
                    name: "FK_AbpUserTokens_AbpUsers_UserId",
                    column: x => x.UserId,
                    principalTable: "AbpUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

        migrationBuilder.CreateTable(
            name: "AbpSettings",
            columns: table => new
            {
                Id = table.Column<long>(nullable: false)
                    .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                CreationTime = table.Column<DateTime>(nullable: false),
                CreatorUserId = table.Column<long>(nullable: true),
                LastModificationTime = table.Column<DateTime>(nullable: true),
                LastModifierUserId = table.Column<long>(nullable: true),
                Name = table.Column<string>(maxLength: 256, nullable: false),
                TenantId = table.Column<int>(nullable: true),
                UserId = table.Column<long>(nullable: true),
                Value = table.Column<string>(maxLength: 2000, nullable: true)
            },
            constraints: table =>
            {
                table.PrimaryKey("PK_AbpSettings", x => x.Id);
                table.ForeignKey(
                    name: "FK_AbpSettings_AbpUsers_UserId",
                    column: x => x.UserId,
                    principalTable: "AbpUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

        migrationBuilder.CreateTable(
            name: "AbpRoles",
            columns: table => new
            {
                Id = table.Column<int>(nullable: false)
                    .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                ConcurrencyStamp = table.Column<string>(nullable: true),
                CreationTime = table.Column<DateTime>(nullable: false),
                CreatorUserId = table.Column<long>(nullable: true),
                DeleterUserId = table.Column<long>(nullable: true),
                DeletionTime = table.Column<DateTime>(nullable: true),
                DisplayName = table.Column<string>(maxLength: 64, nullable: false),
                IsDefault = table.Column<bool>(nullable: false),
                IsDeleted = table.Column<bool>(nullable: false),
                IsStatic = table.Column<bool>(nullable: false),
                LastModificationTime = table.Column<DateTime>(nullable: true),
                LastModifierUserId = table.Column<long>(nullable: true),
                Name = table.Column<string>(maxLength: 32, nullable: false),
                NormalizedName = table.Column<string>(maxLength: 32, nullable: false),
                TenantId = table.Column<int>(nullable: true)
            },
            constraints: table =>
            {
                table.PrimaryKey("PK_AbpRoles", x => x.Id);
                table.ForeignKey(
                    name: "FK_AbpRoles_AbpUsers_CreatorUserId",
                    column: x => x.CreatorUserId,
                    principalTable: "AbpUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
                table.ForeignKey(
                    name: "FK_AbpRoles_AbpUsers_DeleterUserId",
                    column: x => x.DeleterUserId,
                    principalTable: "AbpUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
                table.ForeignKey(
                    name: "FK_AbpRoles_AbpUsers_LastModifierUserId",
                    column: x => x.LastModifierUserId,
                    principalTable: "AbpUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

        migrationBuilder.CreateTable(
            name: "AbpTenants",
            columns: table => new
            {
                Id = table.Column<int>(nullable: false)
                    .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                ConnectionString = table.Column<string>(maxLength: 1024, nullable: true),
                CreationTime = table.Column<DateTime>(nullable: false),
                CreatorUserId = table.Column<long>(nullable: true),
                DeleterUserId = table.Column<long>(nullable: true),
                DeletionTime = table.Column<DateTime>(nullable: true),
                EditionId = table.Column<int>(nullable: true),
                IsActive = table.Column<bool>(nullable: false),
                IsDeleted = table.Column<bool>(nullable: false),
                LastModificationTime = table.Column<DateTime>(nullable: true),
                LastModifierUserId = table.Column<long>(nullable: true),
                Name = table.Column<string>(maxLength: 128, nullable: false),
                TenancyName = table.Column<string>(maxLength: 64, nullable: false)
            },
            constraints: table =>
            {
                table.PrimaryKey("PK_AbpTenants", x => x.Id);
                table.ForeignKey(
                    name: "FK_AbpTenants_AbpUsers_CreatorUserId",
                    column: x => x.CreatorUserId,
                    principalTable: "AbpUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
                table.ForeignKey(
                    name: "FK_AbpTenants_AbpUsers_DeleterUserId",
                    column: x => x.DeleterUserId,
                    principalTable: "AbpUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
                table.ForeignKey(
                    name: "FK_AbpTenants_AbpEditions_EditionId",
                    column: x => x.EditionId,
                    principalTable: "AbpEditions",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
                table.ForeignKey(
                    name: "FK_AbpTenants_AbpUsers_LastModifierUserId",
                    column: x => x.LastModifierUserId,
                    principalTable: "AbpUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

        migrationBuilder.CreateTable(
            name: "AbpPermissions",
            columns: table => new
            {
                Id = table.Column<long>(nullable: false)
                    .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                CreationTime = table.Column<DateTime>(nullable: false),
                CreatorUserId = table.Column<long>(nullable: true),
                Discriminator = table.Column<string>(nullable: false),
                IsGranted = table.Column<bool>(nullable: false),
                Name = table.Column<string>(maxLength: 128, nullable: false),
                TenantId = table.Column<int>(nullable: true),
                RoleId = table.Column<int>(nullable: true),
                UserId = table.Column<long>(nullable: true)
            },
            constraints: table =>
            {
                table.PrimaryKey("PK_AbpPermissions", x => x.Id);
                table.ForeignKey(
                    name: "FK_AbpPermissions_AbpRoles_RoleId",
                    column: x => x.RoleId,
                    principalTable: "AbpRoles",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_AbpPermissions_AbpUsers_UserId",
                    column: x => x.UserId,
                    principalTable: "AbpUsers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

        migrationBuilder.CreateTable(
            name: "AbpRoleClaims",
            columns: table => new
            {
                Id = table.Column<long>(nullable: false)
                    .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                ClaimType = table.Column<string>(nullable: true),
                ClaimValue = table.Column<string>(nullable: true),
                CreationTime = table.Column<DateTime>(nullable: false),
                CreatorUserId = table.Column<long>(nullable: true),
                RoleId = table.Column<int>(nullable: false),
                TenantId = table.Column<int>(nullable: true),
                UserId = table.Column<int>(nullable: true)
            },
            constraints: table =>
            {
                table.PrimaryKey("PK_AbpRoleClaims", x => x.Id);
                table.ForeignKey(
                    name: "FK_AbpRoleClaims_AbpRoles_UserId",
                    column: x => x.UserId,
                    principalTable: "AbpRoles",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
            });

        migrationBuilder.CreateIndex(
            name: "IX_AbpFeatures_EditionId_Name",
            table: "AbpFeatures",
            columns: new[] { "EditionId", "Name" });

        migrationBuilder.CreateIndex(
            name: "IX_AbpFeatures_TenantId_Name",
            table: "AbpFeatures",
            columns: new[] { "TenantId", "Name" });

        migrationBuilder.CreateIndex(
            name: "IX_AbpAuditLogs_TenantId_ExecutionDuration",
            table: "AbpAuditLogs",
            columns: new[] { "TenantId", "ExecutionDuration" });

        migrationBuilder.CreateIndex(
            name: "IX_AbpAuditLogs_TenantId_ExecutionTime",
            table: "AbpAuditLogs",
            columns: new[] { "TenantId", "ExecutionTime" });

        migrationBuilder.CreateIndex(
            name: "IX_AbpAuditLogs_TenantId_UserId",
            table: "AbpAuditLogs",
            columns: new[] { "TenantId", "UserId" });

        migrationBuilder.CreateIndex(
            name: "IX_AbpPermissions_TenantId_Name",
            table: "AbpPermissions",
            columns: new[] { "TenantId", "Name" });

        migrationBuilder.CreateIndex(
            name: "IX_AbpPermissions_RoleId",
            table: "AbpPermissions",
            column: "RoleId");

        migrationBuilder.CreateIndex(
            name: "IX_AbpPermissions_UserId",
            table: "AbpPermissions",
            column: "UserId");

        migrationBuilder.CreateIndex(
            name: "IX_AbpRoleClaims_RoleId",
            table: "AbpRoleClaims",
            column: "RoleId");

        migrationBuilder.CreateIndex(
            name: "IX_AbpRoleClaims_UserId",
            table: "AbpRoleClaims",
            column: "UserId");

        migrationBuilder.CreateIndex(
            name: "IX_AbpRoleClaims_TenantId_ClaimType",
            table: "AbpRoleClaims",
            columns: new[] { "TenantId", "ClaimType" });

        migrationBuilder.CreateIndex(
            name: "IX_AbpUserAccounts_EmailAddress",
            table: "AbpUserAccounts",
            column: "EmailAddress");

        migrationBuilder.CreateIndex(
            name: "IX_AbpUserAccounts_UserName",
            table: "AbpUserAccounts",
            column: "UserName");

        migrationBuilder.CreateIndex(
            name: "IX_AbpUserAccounts_TenantId_EmailAddress",
            table: "AbpUserAccounts",
            columns: new[] { "TenantId", "EmailAddress" });

        migrationBuilder.CreateIndex(
            name: "IX_AbpUserAccounts_TenantId_UserId",
            table: "AbpUserAccounts",
            columns: new[] { "TenantId", "UserId" });

        migrationBuilder.CreateIndex(
            name: "IX_AbpUserAccounts_TenantId_UserName",
            table: "AbpUserAccounts",
            columns: new[] { "TenantId", "UserName" });

        migrationBuilder.CreateIndex(
            name: "IX_AbpUserClaims_UserId",
            table: "AbpUserClaims",
            column: "UserId");

        migrationBuilder.CreateIndex(
            name: "IX_AbpUserClaims_TenantId_ClaimType",
            table: "AbpUserClaims",
            columns: new[] { "TenantId", "ClaimType" });

        migrationBuilder.CreateIndex(
            name: "IX_AbpUserLogins_UserId",
            table: "AbpUserLogins",
            column: "UserId");

        migrationBuilder.CreateIndex(
            name: "IX_AbpUserLogins_TenantId_UserId",
            table: "AbpUserLogins",
            columns: new[] { "TenantId", "UserId" });

        migrationBuilder.CreateIndex(
            name: "IX_AbpUserLogins_TenantId_LoginProvider_ProviderKey",
            table: "AbpUserLogins",
            columns: new[] { "TenantId", "LoginProvider", "ProviderKey" });

        migrationBuilder.CreateIndex(
            name: "IX_AbpUserLoginAttempts_UserId_TenantId",
            table: "AbpUserLoginAttempts",
            columns: new[] { "UserId", "TenantId" });

        migrationBuilder.CreateIndex(
            name: "IX_AbpUserLoginAttempts_TenancyName_UserNameOrEmailAddress_Result",
            table: "AbpUserLoginAttempts",
            columns: new[] { "TenancyName", "UserNameOrEmailAddress", "Result" });

        migrationBuilder.CreateIndex(
            name: "IX_AbpUserOrganizationUnits_TenantId_OrganizationUnitId",
            table: "AbpUserOrganizationUnits",
            columns: new[] { "TenantId", "OrganizationUnitId" });

        migrationBuilder.CreateIndex(
            name: "IX_AbpUserOrganizationUnits_TenantId_UserId",
            table: "AbpUserOrganizationUnits",
            columns: new[] { "TenantId", "UserId" });

        migrationBuilder.CreateIndex(
            name: "IX_AbpUserRoles_UserId",
            table: "AbpUserRoles",
            column: "UserId");

        migrationBuilder.CreateIndex(
            name: "IX_AbpUserRoles_TenantId_RoleId",
            table: "AbpUserRoles",
            columns: new[] { "TenantId", "RoleId" });

        migrationBuilder.CreateIndex(
            name: "IX_AbpUserRoles_TenantId_UserId",
            table: "AbpUserRoles",
            columns: new[] { "TenantId", "UserId" });

        migrationBuilder.CreateIndex(
            name: "IX_AbpUserTokens_UserId",
            table: "AbpUserTokens",
            column: "UserId");

        migrationBuilder.CreateIndex(
            name: "IX_AbpUserTokens_TenantId_UserId",
            table: "AbpUserTokens",
            columns: new[] { "TenantId", "UserId" });

        migrationBuilder.CreateIndex(
            name: "IX_AbpBackgroundJobs_IsAbandoned_NextTryTime",
            table: "AbpBackgroundJobs",
            columns: new[] { "IsAbandoned", "NextTryTime" });

        migrationBuilder.CreateIndex(
            name: "IX_AbpSettings_UserId",
            table: "AbpSettings",
            column: "UserId");

        migrationBuilder.CreateIndex(
            name: "IX_AbpSettings_TenantId_Name",
            table: "AbpSettings",
            columns: new[] { "TenantId", "Name" });

        migrationBuilder.CreateIndex(
            name: "IX_AbpLanguages_TenantId_Name",
            table: "AbpLanguages",
            columns: new[] { "TenantId", "Name" });

        migrationBuilder.CreateIndex(
            name: "IX_AbpLanguageTexts_TenantId_Source_LanguageName_Key",
            table: "AbpLanguageTexts",
            columns: new[] { "TenantId", "Source", "LanguageName", "Key" });

        migrationBuilder.CreateIndex(
            name: "IX_AbpNotificationSubscriptions_NotificationName_EntityTypeName_EntityId_UserId",
            table: "AbpNotificationSubscriptions",
            columns: new[] { "NotificationName", "EntityTypeName", "EntityId", "UserId" });

        migrationBuilder.CreateIndex(
            name: "IX_AbpNotificationSubscriptions_TenantId_NotificationName_EntityTypeName_EntityId_UserId",
            table: "AbpNotificationSubscriptions",
            columns: new[] { "TenantId", "NotificationName", "EntityTypeName", "EntityId", "UserId" });

        migrationBuilder.CreateIndex(
            name: "IX_AbpTenantNotifications_TenantId",
            table: "AbpTenantNotifications",
            column: "TenantId");

        migrationBuilder.CreateIndex(
            name: "IX_AbpUserNotifications_UserId_State_CreationTime",
            table: "AbpUserNotifications",
            columns: new[] { "UserId", "State", "CreationTime" });

        migrationBuilder.CreateIndex(
            name: "IX_AbpOrganizationUnits_ParentId",
            table: "AbpOrganizationUnits",
            column: "ParentId");

        migrationBuilder.CreateIndex(
            name: "IX_AbpOrganizationUnits_TenantId_Code",
            table: "AbpOrganizationUnits",
            columns: new[] { "TenantId", "Code" });

        migrationBuilder.CreateIndex(
            name: "IX_AbpRoles_CreatorUserId",
            table: "AbpRoles",
            column: "CreatorUserId");

        migrationBuilder.CreateIndex(
            name: "IX_AbpRoles_DeleterUserId",
            table: "AbpRoles",
            column: "DeleterUserId");

        migrationBuilder.CreateIndex(
            name: "IX_AbpRoles_LastModifierUserId",
            table: "AbpRoles",
            column: "LastModifierUserId");

        migrationBuilder.CreateIndex(
            name: "IX_AbpRoles_TenantId_NormalizedName",
            table: "AbpRoles",
            columns: new[] { "TenantId", "NormalizedName" });

        migrationBuilder.CreateIndex(
            name: "IX_AbpUsers_CreatorUserId",
            table: "AbpUsers",
            column: "CreatorUserId");

        migrationBuilder.CreateIndex(
            name: "IX_AbpUsers_DeleterUserId",
            table: "AbpUsers",
            column: "DeleterUserId");

        migrationBuilder.CreateIndex(
            name: "IX_AbpUsers_LastModifierUserId",
            table: "AbpUsers",
            column: "LastModifierUserId");

        migrationBuilder.CreateIndex(
            name: "IX_AbpUsers_TenantId_NormalizedEmailAddress",
            table: "AbpUsers",
            columns: new[] { "TenantId", "NormalizedEmailAddress" });

        migrationBuilder.CreateIndex(
            name: "IX_AbpUsers_TenantId_NormalizedUserName",
            table: "AbpUsers",
            columns: new[] { "TenantId", "NormalizedUserName" });

        migrationBuilder.CreateIndex(
            name: "IX_AbpTenants_CreatorUserId",
            table: "AbpTenants",
            column: "CreatorUserId");

        migrationBuilder.CreateIndex(
            name: "IX_AbpTenants_DeleterUserId",
            table: "AbpTenants",
            column: "DeleterUserId");

        migrationBuilder.CreateIndex(
            name: "IX_AbpTenants_EditionId",
            table: "AbpTenants",
            column: "EditionId");

        migrationBuilder.CreateIndex(
            name: "IX_AbpTenants_LastModifierUserId",
            table: "AbpTenants",
            column: "LastModifierUserId");

        migrationBuilder.CreateIndex(
            name: "IX_AbpTenants_TenancyName",
            table: "AbpTenants",
            column: "TenancyName");
    }

    protected override void Down(MigrationBuilder migrationBuilder)
    {
        migrationBuilder.DropTable(
            name: "AbpFeatures");

        migrationBuilder.DropTable(
            name: "AbpAuditLogs");

        migrationBuilder.DropTable(
            name: "AbpPermissions");

        migrationBuilder.DropTable(
            name: "AbpRoleClaims");

        migrationBuilder.DropTable(
            name: "AbpUserAccounts");

        migrationBuilder.DropTable(
            name: "AbpUserClaims");

        migrationBuilder.DropTable(
            name: "AbpUserLogins");

        migrationBuilder.DropTable(
            name: "AbpUserLoginAttempts");

        migrationBuilder.DropTable(
            name: "AbpUserOrganizationUnits");

        migrationBuilder.DropTable(
            name: "AbpUserRoles");

        migrationBuilder.DropTable(
            name: "AbpUserTokens");

        migrationBuilder.DropTable(
            name: "AbpBackgroundJobs");

        migrationBuilder.DropTable(
            name: "AbpSettings");

        migrationBuilder.DropTable(
            name: "AbpLanguages");

        migrationBuilder.DropTable(
            name: "AbpLanguageTexts");

        migrationBuilder.DropTable(
            name: "AbpNotifications");

        migrationBuilder.DropTable(
            name: "AbpNotificationSubscriptions");

        migrationBuilder.DropTable(
            name: "AbpTenantNotifications");

        migrationBuilder.DropTable(
            name: "AbpUserNotifications");

        migrationBuilder.DropTable(
            name: "AbpOrganizationUnits");

        migrationBuilder.DropTable(
            name: "AbpTenants");

        migrationBuilder.DropTable(
            name: "AbpRoles");

        migrationBuilder.DropTable(
            name: "AbpEditions");

        migrationBuilder.DropTable(
            name: "AbpUsers");
    }
}
